﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SimpleORM.Extensions;
using SimpleORM.Infrastructure.Concurrency;
using SimpleORM.Infrastructure.Swagger;
using SimpleORM.Infrastructure.SYSApiAuthorize;
using SimpleORM.Model.DataBaseModel.SYSModelmain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleORM.Infrastructure
{
    public static class SYSSetUp
    {
        public static IServiceCollection AddSYSSetUp(this IServiceCollection services,IConfiguration configuration)
        {
            
            services.AddSingleton(new AppSettings(configuration));
            //注入sqlsugar
            services.AddSqlsugarSetup();
            //注册ioc
            services.AddBusiness(); 
            //注入单独类
            services.AddAttribute();
            //幂等请求
            //services.AddScoped<SemaphoreActionFilter>();         
            // 注册API控制器服务
            services.AddControllers(options =>
            {
                // 添加MyAuthentication过滤器
                options.Filters.Add<MyAuthentication>();
                options.Filters.Add<RequestFilter>();
            });
            services.AddScoped<UserMage>(); 
            //Swagger请求验证Header
            //services.AddSwaggerGen(c =>
            //{
            //    c.OperationFilter<RequestValidSignSwaggerOperationFilter>();
            //});
            return services;
        }
    }
}
